package com.ruoyi.web.controller.controllers;


import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.provider.domain.AhctDefineDamage;
import com.ruoyi.provider.domain.AhctDefineDamageCode;
import com.ruoyi.provider.service.AhctDefineDamageService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/*
 * 定损报批信息
 */

@RestController
@RequestMapping("/damage")
public class AhctDamageController extends BaseController {


    @Resource
    private AhctDefineDamageService ahctDefineDamageService;


    //获取定损列表
    @GetMapping("/getDamageList")
    public AjaxResult getDamage(AhctDefineDamage ahctDefineDamage, int pageNum, int pageSize){

        PageInfo<AhctDefineDamage> pageInfo = ahctDefineDamageService.getDamage(ahctDefineDamage,pageNum,pageSize);
        return success(pageInfo);
    }

    //新增定损项目
    @PostMapping("/insertDamage")
    public AjaxResult insertDamage(@RequestBody AhctDefineDamageCode ahctDefineDamageCode){

        ahctDefineDamageService.insertDamage(ahctDefineDamageCode);
        return success(0);
    }

    //定损信息修改
    @PostMapping("/updateDamage")
    public AjaxResult updateDamage(@RequestBody AhctDefineDamageCode ahctDefineDamageCode){

        ahctDefineDamageService.updateDamage(ahctDefineDamageCode);
        return success(0);
    }

    //定损信息删除
    @PostMapping("/deleteDamage")
    public AjaxResult deleteDamage(@RequestBody AhctDefineDamage ahctDefineDamage){

        ahctDefineDamageService.deleteDamage(ahctDefineDamage.getId(),ahctDefineDamage.getCase_number());
        return success(0);
    }

    //定损审核
    //修改审核后,还未实现在核损页面的新增代码操作,原因服务器暂未创建核损项目明细表
    @GetMapping("/updateStatus")
    public AjaxResult updateStatus(@RequestParam String status, String case_number){

        ahctDefineDamageService.updateStatus(status,case_number);
        return success(0);
    }
}